<template>
    <div>
        <h1>等级添加</h1>
    </div>
    <table class="table table-bprdered">
        <tbody>
            <tr>
                <td>等级名称</td>
                <td><input type="text" v-model="info.userVipName"></td>
            </tr>
            <tr>
                <td>状态</td>
                <td>
                    <input type="radio" name="state" v-model="info.state" :value="1">启用
                    <input type="radio" name="state" v-model="info.state" :value="0">禁用

                </td>
            </tr>
            <tr>
                <td>权益</td>
                <td>
                    <input type="checkbox" name="a" v-model="info.userVipQ" value="免费早餐">免费早餐
                    <input type="checkbox" name="a" v-model="info.userVipQ" value="9.9折">9.9折
                    <input type="checkbox" name="a" v-model="info.userVipQ" value="9折">9折
                    <input type="checkbox" name="a" v-model="info.userVipQ" value="100代金券">100代金券
                    <input type="checkbox" name="a" v-model="info.userVipQ" value="接送服务">接送服务
                    <input type="checkbox" name="a" v-model="info.userVipQ" value="75折">75折
                    <input type="checkbox" name="a" v-model="info.userVipQ" value="50代金券">50代金券
                </td>
            </tr>
            <tr>
                <td>消费金额</td>
                <td><input type="text" v-model="info.price"></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="button" value="确定" @click="add"></td>
            </tr>
        </tbody>
    </table>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import axios from 'axios';
import { useRoute, useRouter } from 'vue-router';
const route = useRoute();
const router = useRouter();


let info: any = reactive({
    "userVipName": "",
    "state": '',
    "userVipQ": [],
    "price": '',
})

const add = () => {
    info.userVipQ = info.userVipQ.toString();
    axios({
        url: 'https://localhost:7173/api/User/AddMenber',
        method: 'post',
        data: info,
    })
        .then(res => {
            if (res.data > 0) {
                alert("添加成功");

                return;
            }
            else if (res.data == -1) {
                alert("不要重复添加等级");
                return;
            }
            else {
                alert("添加失败");
                return;
            }
        })
}
</script>





<style scoped></style>